<template>
<!--  @ok="handleSubmit"-->

  <BasicModal
    v-bind="$attrs"
    @register="register"
    showFooter
    :title="getTitle"
    width="50%"
  >
    <BasicTable @register="registerTable">

    </BasicTable>
  </BasicModal>
</template>
<script lang="ts" setup>
  import { ref, computed, unref } from 'vue';
  import { BasicModal, useModalInner } from '@/components/Modal';
  import { BasicTree, TreeItem } from '@/components/Tree';
  import { getUsersApi} from '@/api/sys/clazz';
  import { BasicTable, useTable, TableAction } from '@/components/Table';

  import {useMessage} from "@/hooks/web/useMessage";

  const emit = defineEmits(['success', 'register']);
  const isUpdate = ref(true);
  const treeData = ref<TreeItem[]>([]);
  const { createMessage } = useMessage();

  const clazzId =ref("");
  const levelNames=ref("");

  const user_columns=[
    {
      title: '姓名',
      dataIndex: 'userName',
    }
  ]
  const user_schemas=[
    {
      field: 'keyword',
      label: '姓名',
      component: 'Input',
      colProps: { span: 8 },
    }
  ]
  const [registerTable, { reload }] = useTable({
    title: '班级成员列表',
    api: getUsersApi,
    immediate:false,
    columns:user_columns,
    formConfig: {
      labelWidth: 120,
      schemas: user_schemas,
      autoSubmitOnEnter: true
    },
    beforeFetch:function (p){
      p.levelNames=levelNames.value;
    //  console.log("---p:",p)
      return p;
    },
    useSearchForm: true,
    showTableSetting: true,
    bordered: true,
    showIndexColumn: false,
    // actionColumn: {
    //   width: 80,
    //   title: '操作',
    //   dataIndex: 'action',
    //   fixed: undefined,
    // },
  });


  const [register, { setModalProps, closeModal }] = useModalInner(async (data) => {
    //console.log("--data::",data)
    //打开弹层后的回调
    // clazzId.value=data.clazzId;
    levelNames.value=data.levelNames;
    reload()
  });


  const getTitle = ref("群成员");

</script>
